home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_d / cpltest.zip / CPLHEADR.PAS next >
Pascal/Delphi Source File  |  1996-01-10  |  5KB  |  156 lines

  1. unit Cplheadr;
  2.  
  3. {*
  4. ** CREDITS:
  5. **          I had been strugling with converting my old C Control Panel
  6. **          Applications into DELPHI (No particular reason.. Just could it be
  7. **          done?) As a C-man I found DELPHI's documentation (rather lack
  8. **          thereof) not very helpful... so I turned to the man with the answers,
  9. **          Kurt Barthelmess of Team B.  He pointed out my errors and boy did
  10. **          I feel 100% stupid. I've done PASCAL for 4 years and I felt like
  11. **          a 3 month cadet after Kurt pointed my obvious errors out to me.
  12. **          Looking past my ignorance, Kurt pointed me in the right direction.
  13. **          So, if you like this unit, remember to thank Kurt "The Man" Barthelmess.
  14. **
  15. **          Also, in certain parts of this code I para-quote the CPL.INT
  16. **          file found in the DELPHI/DOC directory as pertaining to the
  17. **          CPL_xxx messages.
  18. *}
  19.  
  20. {*
  21. ** Entered into the Public Domain by David A. Rigsby on January 10, 1996.
  22. ** Use this unit and Functions at your own risk. Feel free to modify and
  23. ** redistribute on the condition that any revisions keep this original
  24. ** header or in some way bears the name of the Author and those who may
  25. ** have modified and redistributed it. Always remember, Give Credit where
  26. ** Credit is due.... and you will feel SOOOOOOO Good about yourself..
  27. ** Ompa loompa dompa de do.....
  28. **
  29. ** NOTE: Even though this is being entered into Public Domain, it may
  30. **       in no wise be copied or reproduced in a literary work,
  31. **       such as a Book, Video, Electronic Books, Code Sniplets,
  32. **       etc, without the express consent of the Author, David Rigsby,
  33. **       Who may be contacted via E-Mail at: BranhamTch@aol.com.
  34. **       Im a nice guy, just give me a chance......
  35. **
  36. ** NOTE** And if there is anybody out there looking for contributors
  37. **        for Books, Videos, etc.. I'm your man. Just contact me
  38. **        via E-Mail at BranhamTch@aol.com and I will be more than happy
  39. **        to contribute my Hundreds of Code Samples and Sniplets that
  40. **        have taken over 6 years to compile. Here are some of the
  41. **        languages I am Proficient in:
  42. **
  43. **        C DOS/Windows, C++ DOS/Windows, Pascal DOS, Pascal DELPHI,
  44. **        UNIX Kornshell, UNIX C, AS/400 RPG, and many more.
  45. **
  46. *}
  47.  
  48. interface
  49. uses SysUtils,Forms,WinTypes,CPL;
  50.  
  51. {*
  52. ** Declare the CALLBACK (psuedo) for CPLApplet, the Control Panel will expect this.
  53. ** Remember, when you have integrated this unit into your application, in your
  54. ** Project source add the following line:
  55. **                    EXPORTS
  56. **                           CPLAPPLET;
  57. **
  58. *}
  59. function CPLApplet (hWndCpl: HWnd; msg: Word;lParam1:LONGINT;var NewCPLInfo: TNEWCPLINFO): Longint;export;
  60.  
  61. implementation
  62. {*
  63. ** For this project, my form dialog is called MainDlg. For the sake of reusability,
  64. ** I have made this CPL unit separate from my application. You can always take everything
  65. ** in this UNIT and PASTE it into your Main Unit. That would be cool. Right now, I have
  66. ** This unit setup as a Template which I add to my projects and simply modify a
  67. ** couple of Parameters.
  68. *}
  69. uses Maindlg;
  70.  
  71. function CPLApplet (hWndCpl: HWnd; msg: Word;lParam1:LONGINT;var NewCPLInfo: TNEWCPLINFO): Longint;
  72. begin
  73.  
  74.  case msg of
  75.   CPL_INIT:
  76.   begin
  77. {*
  78. ** This message is sent to indicate CPlApplet() was found.
  79. **  Return TRUE or FALSE indicating whether the control panel should proceed.
  80. *}
  81.    CPlApplet:=1;
  82.   end;
  83.  
  84.   CPL_GETCOUNT:
  85. {*
  86. ** How many applets do you wish?
  87. ** If this is greater than 1, the Control Panel will
  88. ** send the CPL_NEWINQUIRE message for that many applications.
  89. ** EX: If you return 3, CPL_NEWINQUIRE will be sent to you 3
  90. **     times. Each time control panel will be expecting information
  91. **     as pertaining to each of the Three Applets to be displayed.
  92. ** For this example, we'll just do one.
  93. *}
  94.     CPlApplet:=1;
  95.  
  96.  
  97.   CPL_NEWINQUIRE:
  98.   begin
  99. {*
  100. ** This was the bear. This is majorly what Kurt helped me with.
  101. ** I couldn't seem to get the function prototype correct enough
  102. ** to get this code to compile much less work correctly.
  103. *}
  104.  
  105.    with NewCPLInfo do
  106.    begin
  107.     {*
  108.     ** Like good boys and girls, we must initialize the SIZE of our
  109.     ** Structure so windows won't choke on us!
  110.     *}
  111.       dwSize:=sizeof(TNEWCPLINFO);
  112.       dwFlags := 0;
  113.       dwHelpContext := 0;
  114.       lData := 0;
  115.      {*
  116.      ** I rarlely modify this. I usually associate an ICON with my
  117.      ** DLL and just reference it this way. (Options | Project | Application)
  118.      *}
  119.       Icon :=Application.Icon.Handle;
  120.       szHelpFile[0]:= #0;
  121.      {*
  122.      ** This displays a Short Description in the Control Panel's Window
  123.      *}
  124.       StrPCopy(szName,'DEPLHI Applet');
  125.      {*
  126.      ** This displays a Long Description in the Control Panel's Status Bar.
  127.      *}
  128.       StrPCopy(szInfo,'Wonderful Control Panel Test. Double click and see the magic!');
  129.    end;
  130.   end;
  131.  
  132.   CPL_DBLCLK:
  133.   {*
  134.   ** The user Double Clicked and wants to activate us.
  135.   ** Create the Form and Show it MODAL!
  136.   *}
  137.   begin
  138.    MainForm:=TMainForm.Create(Application);
  139.    MainForm.ShowModal;
  140.   end;
  141.  
  142.   {*
  143.   ** There are more messages like CPL_STOP and CPL_DBLCLK, but we won't respond to
  144.   ** them.  Feel Free to do so if you want to.
  145.   *}
  146. {
  147.   CPL_STOP:;
  148.  
  149.   CPL_EXIT:;
  150.  }
  151.  end;
  152. end;
  153.  
  154.  
  155. end.
  156.